//
//  productProfileTableViewCell.m
//  代码布局
//
//  Created by iOS on 16/7/27.
//  Copyright © 2016年 iOS. All rights reserved.
//

#import "productProfileTableViewCell.h"
#import "getStringOfHeightOfReact.h"
#import "commodityProfileSuffix.h"
#import "getLabelCharPoint.h"
#import "promotionInfoView.h"
@interface productProfileTableViewCell()<UITextViewDelegate,UIGestureRecognizerDelegate,countDownDelegate>
@property(nonatomic,strong)UILabel * basicInfoLabel;
@property(nonatomic,strong)UILabel * offerTipLabel;
@property(nonatomic,strong)UITextView * offerTipTextView;
@property(nonatomic,strong)UILabel * productPriceLabel;
@property(nonatomic,strong)UILabel * productOriginPriceLabel;
@property(nonatomic,strong)UIButton* lowerPriceNoticeBtn;
@property(nonatomic,strong)UILabel * exclusiveMobilePhoneLabel;

@property(nonatomic,strong)UIView *WhiteIouLine;
@property(nonatomic,strong)countDown * countdown;
@property(nonatomic,strong)UILabel *WhiteIouLineTitle;
@property(nonatomic,strong)UILabel *WhiteIouLineInfo;
@property(nonatomic,strong)EllipsisView * WhiteIouEll;
@property(nonatomic,strong)UIButton *  EllButton;
//促销
@property(nonatomic,strong)UIView * promotionLine;
@property(nonatomic,strong)UILabel * promotionTitle;
@property(nonatomic,strong)EllipsisView *promotionEll;
@property(nonatomic,strong)promotionInfoView *promotionInfo;
@property(nonatomic,strong)UIButton *  promotionButton;
@end
@implementation productProfileTableViewCell
static CGFloat basicInfoHeight = 0;
static CGFloat offerTipHeight = 0;
static CGFloat productPriceHeight = 0;
static CGFloat ExclusiveMobilePhoneHeight = 0;
static CGFloat WhiteIouHeight = 0;
static CGFloat promotionHeight = 0;
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       // self.backgroundColor = [UIColor yellowColor];
        // [self createPromotionView];
      //  UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 297, WIDTH, 3)];
      //  view.backgroundColor = [UIColor yellowColor];
       // [self addSubview:view];
    }
    return self;
}
#pragma mark 大文字简介
-(void)basicInformationProfile:(NSString*)infoString{
    
        NSMutableAttributedString *attri =     [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@  ",infoString] ];
    
    NSTextAttachment *attch = [[NSTextAttachment alloc] init];
    // 表情图片
    UIImage *image = [commodityProfileSuffix watermarkImage:@"自 营"];
    attch.image = image;
    
    // 设置图片大小
    attch.bounds = CGRectMake(0, 0, image.size.width, image.size.height);
    
    // 创建带有图片的富文本
    NSAttributedString *string2 = [NSAttributedString attributedStringWithAttachment:attch];
    [attri appendAttributedString:string2];
    
    
 //   UILabel * basicInfoLabel = [[UILabel alloc]init];
 //   basicInfoLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.basicInfoLabel];
  CGFloat height =  [getStringOfHeightOfReact getstringHeight:infoString AndStringFont:fontNunber(16) AndLineSpace:2 andStringWidth:WIDTH - 16];
    basicInfoHeight = height + 10;
    NSLog(@"=========%f",height);
    [self.basicInfoLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.left).offset(8.0);
        make.right.equalTo(self.right).offset(-8.0);
        make.top.equalTo(self.top).offset(10.0);
        make.height.equalTo(height);
        
    }];
   self.basicInfoLabel.attributedText = attri;
    self.basicInfoLabel.numberOfLines = 0;
    self.basicInfoLabel.font = [UIFont systemFontOfSize:fontNunber(16)];
   }
- (void)setBasicInfoString:(NSString *)basicInfoString{
    _basicInfoString = basicInfoString;
    [self basicInformationProfile:basicInfoString];
}

- (UILabel*)basicInfoLabel{
    if (!_basicInfoLabel) {
        self.basicInfoLabel = [[UILabel alloc]init];
    }
    return _basicInfoLabel;
}


#pragma mark 红色文字简介

- (UILabel*)offerTipLabel{
    if (!_offerTipLabel) {
        _offerTipLabel = [[UILabel alloc]init];

    }
    return _offerTipLabel;
}
- (void)setOfferTipsString:(NSString *)OfferTipsString{
    _OfferTipsString = OfferTipsString;
    [self offerTipStringLabel:OfferTipsString];
  //  [self offerTipStringTextView:OfferTipsString];
}
- (void)offerTipStringLabel:(NSString*)offerString{
    CGFloat lineSpace = 1;
CGFloat height =  [getStringOfHeightOfReact getstringHeight:offerString AndStringFont:fontNunber(12) AndLineSpace:lineSpace andStringWidth:WIDTH - 16];

    [self.contentView addSubview:self.offerTipLabel];
    
    [self.offerTipLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top).offset(basicInfoHeight + 3.0);
        make.height.equalTo(height);
        make.left.equalTo(self.left).offset(8.0);
        make.right.equalTo(self.right).offset(-8.0);
           }];
    offerTipHeight = height + 3.0;
  //  NSURL * url = [NSURL URLWithString:@"http://www.baidu.com"];
    NSMutableAttributedString * attribString = [[NSMutableAttributedString alloc]initWithString:offerString];
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    
    paragraph.lineSpacing = lineSpace;
    [attribString addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, offerString.length)];
    
    [attribString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:fontNunber(12)] range:NSMakeRange(0, offerString.length)];
    [attribString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, offerString.length)];
    [attribString addAttribute:NSKernAttributeName value:@1 range:NSMakeRange(0, offerString.length)];
   
    self.offerTipLabel.attributedText = attribString;
    self.offerTipLabel.numberOfLines = 0;

    //NSLinkAttributeName  //NSUnderlineStyleAttributeName
    self.offerTipLabel.userInteractionEnabled = YES;
    UIGestureRecognizer * tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                                  action:@selector(userTapGestureDetected:)];
    [self.offerTipLabel addGestureRecognizer:tapRecognizer];
    [self.offerTipLabel sizeToFit];
 }
- (void)setNetOfferTipsString:(NSString *)NetOfferTipsString{
    _NetOfferTipsString = NetOfferTipsString;
    NSMutableAttributedString * attri = [[NSMutableAttributedString alloc]initWithAttributedString:self.offerTipLabel.attributedText];
    NSString * str = [NSString localizedStringWithFormat:@"%@",attri];
    NSRange  range = [str rangeOfString:NetOfferTipsString];
    [attri addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:range];
    self.offerTipLabel.attributedText = attri;
}
- (void)userTapGestureDetected:(UIGestureRecognizer *)recognizer {
    CGPoint point = [recognizer locationInView:self.offerTipLabel];


CFIndex index =    [getLabelCharPoint touchContentOffsetInView:self.offerTipLabel atPoint:point data:self.offerTipLabel.attributedText];
 
    if ((CGFloat)index > self.OfferTipsString.length - self.NetOfferTipsString.length) {
        [self.delegate offerTipLink:self.urlOfferTips andtitle:@"title"];
    }
}

- (void)setUrlOfferTips:(NSString *)urlOfferTips{
    _urlOfferTips = urlOfferTips;
}



#pragma mark 价格和降价通知

- (void)setProductPrice:(NSString *)productPrice{
    _productPrice = productPrice;
    [self createProductPriceLabel];
}
- (UILabel*)productPriceLabel{
    if (!_productPriceLabel) {
        _productPriceLabel = [[UILabel alloc]init];
    }
    return _productPriceLabel;
}
- (void)createProductPriceLabel{
    [self.contentView addSubview:self.productPriceLabel];
    NSDictionary *attrsDict = @{NSFontAttributeName : [UIFont systemFontOfSize:fontNunber(22)] };
    CGSize size1 = [self.productPrice boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrsDict context:nil].size;
    
    NSMutableAttributedString * attri = [[NSMutableAttributedString alloc]initWithString:self.productPrice];
    [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:fontNunber(16)] range:NSMakeRange(0, 1)];
    [attri addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-Bold" size:fontNunber(22)] range:NSMakeRange(1, self.productPrice.length - 1)];
    [attri addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, self.productPrice.length)];
      [self.productPriceLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top).offset(basicInfoHeight + offerTipHeight + 10);
        make.left.equalTo(self.left).offset(10);
        make.height.equalTo(size1.height);
        make.width.equalTo(size1.width);
    }];
    productPriceHeight = size1.height + 10;
    self.productPriceLabel.attributedText = attri;
    
    
//#pragma mark 创建降价通知
    [self.lowerPriceNoticeBtn setTitle:@"降价通知" forState:UIControlStateNormal];
    [self.lowerPriceNoticeBtn addTarget:self action:@selector(priceNoticeClick) forControlEvents:UIControlEventTouchUpInside];
    [self.lowerPriceNoticeBtn setTintColor:[UIColor darkGrayColor]];
    [self.contentView addSubview:self.lowerPriceNoticeBtn];
    [self.lowerPriceNoticeBtn.layer setMasksToBounds:YES];
    self.lowerPriceNoticeBtn.titleLabel.font = [UIFont systemFontOfSize:fontNunber(18)];
    [self.lowerPriceNoticeBtn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
    //边框宽度
    [self.lowerPriceNoticeBtn.layer setBorderWidth:1.0];
    self.lowerPriceNoticeBtn.layer.borderColor=[UIColor lightGrayColor].CGColor;
    [self.lowerPriceNoticeBtn makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.right).offset(-8);
        make.bottom.equalTo(self.productPriceLabel.bottom).offset(0);
        make.height.equalTo(self.productPriceLabel.height);
        make.width.equalTo(80);
    }];
}
- (UIButton*)lowerPriceNoticeBtn{
    if (!_lowerPriceNoticeBtn) {
        _lowerPriceNoticeBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    }
    return _lowerPriceNoticeBtn;
}

- (void)priceNoticeClick{

}
#pragma mark 创建原价lable
- (void)setProductOriginPrice:(NSString *)productOriginPrice{
    _productOriginPrice = productOriginPrice;
    [self createProductOriginPriceLabel];
}
- (UILabel*)productOriginPriceLabel{
    if (!_productOriginPriceLabel) {
        _productOriginPriceLabel = [[UILabel alloc]init];
    }
    return _productOriginPriceLabel;
}
- (void)createProductOriginPriceLabel{
    [self.contentView addSubview:self.productOriginPriceLabel];
    NSDictionary *attrsDict = @{NSFontAttributeName : [UIFont systemFontOfSize:fontNunber(16)] };
    CGSize size1 = [self.productPrice boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrsDict context:nil].size;
     [self.productOriginPriceLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.productPriceLabel.right).offset(0);
        make.bottom.equalTo(self.productPriceLabel.bottom).offset(0);
        make.height.equalTo(size1.height);
        make.width.equalTo(size1.width);
    }];
    NSMutableAttributedString * attri = [[NSMutableAttributedString alloc]initWithString:self.productOriginPrice];
    [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:fontNunber(16)] range:NSMakeRange(0, self.productOriginPrice.length)];
    [attri addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(0, self.productOriginPrice.length)];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid) range:NSMakeRange(0, self.productOriginPrice.length)];
    self.productOriginPriceLabel.attributedText = attri;
 }

#pragma mark 手机专享
- (void)setExclusiveMobilePhoneString:(NSString *)exclusiveMobilePhoneString{
    _exclusiveMobilePhoneString = exclusiveMobilePhoneString;
    [self createExclusiveMobilePhoneLabel];
}
- (UILabel*)exclusiveMobilePhoneLabel{
    if (!_exclusiveMobilePhoneLabel) {
        _exclusiveMobilePhoneLabel = [[UILabel alloc]init];
    }
    return _exclusiveMobilePhoneLabel;
}
- (void)createExclusiveMobilePhoneLabel{
    [self.contentView addSubview:self.exclusiveMobilePhoneLabel];
    self.exclusiveMobilePhoneLabel.text = [NSString stringWithFormat:@"手机专享--比PC端省%@元",self.exclusiveMobilePhoneString];
    self.exclusiveMobilePhoneLabel.textColor = [UIColor redColor];
    self.exclusiveMobilePhoneLabel.font = [UIFont systemFontOfSize:fontNunber(12)];
    [self.exclusiveMobilePhoneLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top).offset(basicInfoHeight + offerTipHeight + productPriceHeight + 5);
        make.left.equalTo(self.left).offset(8);
        make.width.equalTo([getStringOfHeightOfReact getstring:self.exclusiveMobilePhoneLabel.text AndFont:fontNunber(12)].width);
        make.height.equalTo([getStringOfHeightOfReact getstring:self.exclusiveMobilePhoneLabel.text AndFont:fontNunber(12)].height);
    }];
    ExclusiveMobilePhoneHeight = [getStringOfHeightOfReact getstring:self.exclusiveMobilePhoneLabel.text AndFont:fontNunber(12)].height + 5;
}

#pragma mark 创建倒计时
- (void)setCountDownTime:(NSString *)countDownTime{
    _countDownTime = countDownTime;
    [self createCountDownView];
}

- (countDown*)countdown{
    if (!_countdown) {
        _countdown = [[countDown alloc]init];
        _countdown.delegate =self;
      //  NSLog(@)
    }
    return _countdown;
}
- (void)createCountDownView{
    [self.contentView addSubview: self.countdown];
    self.countdown.someTime = self.countDownTime;
    self.countdown.font = [UIFont boldSystemFontOfSize:fontNunber(14)];
    [self.countdown makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.exclusiveMobilePhoneLabel.right).offset( 10);
        make.centerY.equalTo(self.exclusiveMobilePhoneLabel.centerY).offset(0);
       // make.bottom.equalTo(self.exclusiveMobilePhoneLabel.bottom).offset(0);
        make.width.equalTo(150);
        make.height.equalTo(heightNumber6sp(16+4));
    }];
}
  - (void)fntSize:(CGSize)size{
    CGRect frame = self.countdown.frame;
     frame.size = size;
    self.countdown.frame = frame;
    //  NSLog(@"按钮====%@",NSStringFromCGRect(self.countdown.frame));
}
#pragma mark 创建白条
- (void)setWhiteIou:(NSString *)whiteIou{
    _whiteIou = whiteIou;
    [self createWhiteIouLineView];
}

- (UIView*)WhiteIouLine{
    if (!_WhiteIouLine) {
        _WhiteIouLine = [[UIView alloc]init];
    }
    return _WhiteIouLine;
}
- (UILabel*)WhiteIouLineTitle{
    if (!_WhiteIouLineTitle) {
        _WhiteIouLineTitle = [[UILabel alloc]init];
    }
    return _WhiteIouLineTitle;
}
- (UILabel*)WhiteIouLineInfo{
    if (!_WhiteIouLineInfo) {
        _WhiteIouLineInfo = [[UILabel alloc]init];
    }
    return _WhiteIouLineInfo;
}

- (EllipsisView*)WhiteIouEll{
    if (!_WhiteIouEll) {
        _WhiteIouEll = [[EllipsisView alloc]init];
        _WhiteIouEll.reloads = CGSizeMake(25, 25/4.0);
    }
    return _WhiteIouEll;
}

- (UIButton*)EllButton{
    if (!_EllButton) {
        _EllButton = [UIButton buttonWithType:UIButtonTypeSystem];
        _EllButton.backgroundColor = [UIColor clearColor];
        [_EllButton addTarget:self action:@selector(WhiteIouClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _EllButton;
}
- (void)createWhiteIouLineView{
    [self.contentView addSubview:self.WhiteIouLine];
    self.WhiteIouLine.backgroundColor = [UIColor darkGrayColor];
    self.WhiteIouLine.alpha = 0.2;
    [self.WhiteIouLine makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top).offset(basicInfoHeight + offerTipHeight + productPriceHeight + ExclusiveMobilePhoneHeight + 5);
        make.left.equalTo(self.left).offset(8.0);
        make.right.equalTo(self.right).offset(0.0);
        make.height.equalTo(1.0);
    }];
    
#pragma mark  白条标题
    [self.contentView addSubview:self.WhiteIouLineTitle];
    self.WhiteIouLineTitle.textColor = [UIColor grayColor];
    self.WhiteIouLineTitle.font = [UIFont systemFontOfSize:13];
    self.WhiteIouLineTitle.text = @"白条";
    CGSize witeIouTitleSize = [getStringOfHeightOfReact getstring:@"白条" AndFont:13];
    [self.WhiteIouLineTitle makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.WhiteIouLine.bottom).offset(10);
        make.left.equalTo(self.left).offset(8);
        make.width.equalTo(witeIouTitleSize.width);
        make.height.equalTo(witeIouTitleSize.height);
    }];
    
    
#pragma mark 省略号
    [self.contentView addSubview:self.WhiteIouEll];
    [self.WhiteIouEll makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(25);
        make.height.equalTo(25/4.0);
        make.right.equalTo(self.right).offset(-15.0);
        make.centerY.equalTo(self.WhiteIouLineTitle.centerY);
       
    }];
  //  self.WhiteIouEll.reloads = YES;
 #pragma mark  白条内容
    [self.contentView addSubview:self.WhiteIouLineInfo];
    self.WhiteIouLineInfo.textColor = [UIColor blackColor];
    self.WhiteIouLineInfo.font = [UIFont systemFontOfSize:fontNunber(14)];
    self.WhiteIouLineInfo.text = self.whiteIou;
    CGSize WhiteIouLineInfoSize = [getStringOfHeightOfReact getstring:self.whiteIou AndFont:fontNunber(14)];
    [self.WhiteIouLineInfo makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.WhiteIouLineTitle.centerY);
        make.left.equalTo(self.WhiteIouLineTitle.right).offset(20);
        make.right.equalTo(self.WhiteIouEll.left).offset(-5);
        make.height.equalTo(WhiteIouLineInfoSize.height);
    }];
#pragma mark 白条点击效果
    [self.contentView addSubview:self.EllButton];
    CGFloat btnHeiht = 2 * (witeIouTitleSize.height/2.0 + 10);
    NSLog(@"btnHeiht == %f",btnHeiht);
    [self.EllButton makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.left).offset(0);
        make.right.equalTo(self.right).offset(0);
        make.top.equalTo(self.WhiteIouLine.bottom).offset(0);
     //   make.height.equalTo(2 * (CGRectGetMidY(self.WhiteIouLineInfo.frame) - CGRectGetMaxY(self.WhiteIouLine.frame)));
         make.height.equalTo(btnHeiht);
    }];
    WhiteIouHeight = btnHeiht + self.WhiteIouLine.frame.size.height + 5;
}
- (void)WhiteIouClick{
    NSLog(@"白条!!!!!!!!!");
}


#pragma mark 促销条件
- (void)setPromotionDict:(NSDictionary *)promotionDict{
    _promotionDict = promotionDict;
    [self createPromotionView];
}
- (UIView*)promotionLine{
    if (!_promotionLine) {
        _promotionLine = [[UIView alloc]init];
             _promotionLine.alpha = 0.2;
    }
    return _promotionLine;
}
- (UILabel*)promotionTitle{
    if (!_promotionTitle) {
        _promotionTitle = [[UILabel alloc]init];
    }
    return _promotionTitle;
}
- (EllipsisView*)promotionEll{
    if (!_promotionEll) {
        _promotionEll = [[EllipsisView alloc]init];
         _promotionEll.reloads = CGSizeMake(25, 25/4.0);
    }
    return _promotionEll;
}
- (promotionInfoView*)promotionInfo{
    if (!_promotionInfo) {
        _promotionInfo = [[promotionInfoView alloc]init];
           }
    return _promotionInfo;
}
- (UIButton*)promotionButton{
    if (!_promotionButton) {
        _promotionButton = [UIButton buttonWithType:UIButtonTypeSystem];
    }
    return _promotionButton;
}
- (void)createPromotionView{
    self.promotionLine.backgroundColor = [UIColor darkGrayColor];
    self.promotionLine.alpha = 0.2;

 
    [self.contentView addSubview:self.promotionLine];
    [self.promotionLine makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.left).offset(8);
        make.right.equalTo(self.right).offset(0);
        make.height.equalTo(1.0);
        make.top.equalTo(self.top).offset(basicInfoHeight + productPriceHeight + offerTipHeight + ExclusiveMobilePhoneHeight + WhiteIouHeight);
      //   make.top.equalTo(self.top).offset(216.33);
    }];
    
#pragma mark 促销标题
    [self.contentView addSubview:self.promotionTitle];
    self.promotionTitle.text = @"促销";
    self.promotionTitle.textColor = [UIColor grayColor];
    self.promotionTitle.font = [UIFont systemFontOfSize:fontNunber(13)];
    CGSize witeIouTitleSize = [getStringOfHeightOfReact getstring:@"白条" AndFont:fontNunber(13)];
    [self.promotionTitle makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.promotionLine.bottom).offset(10);
        make.left.equalTo(self.left).offset(8);
        make.width.equalTo(witeIouTitleSize.width);
        make.height.equalTo(witeIouTitleSize.height);
    }];
#pragma mark 省略号
    [self.contentView addSubview:self.promotionEll];
    [self.promotionEll makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(25);
        make.height.equalTo(25/4.0);
        make.right.equalTo(self.right).offset(-15.0);
        make.centerY.equalTo(self.promotionTitle.centerY);
        
    }];
#pragma mark  详情
  //  self.promotionInfo.backgroundColor = [UIColor yellowColor];
    CGRect frame = self.promotionInfo.frame;
    frame.size.width = WIDTH - witeIouTitleSize.width - 25 - 15 - 8 - 10 - 5;
    frame.size.height = 10;
    self.promotionInfo.frame = frame;
    NSLog(@"ell=%f ,ti = %f",CGRectGetMinX(self.promotionEll.bounds),CGRectGetMaxX(self.promotionTitle.bounds));

    [self.contentView addSubview:self.promotionInfo];
    [self.promotionInfo makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.promotionTitle.right).offset(20);
        make.right.equalTo(self.promotionEll.left).offset(-5);
       // make.height.equalTo(50);
        make.top.equalTo(self.promotionLine.bottom).offset(10);
    }];
      self.promotionInfo.promotionDict = self.promotionDict;
    CGRect frame1 = self.promotionInfo.frame;
    frame1.size = [self.promotionInfo fittedSize];
    self.promotionInfo.frame = frame1;
    NSLog(@"self.promotionInfo=%f",self.promotionInfo.frame.size.height);
    promotionHeight = self.promotionInfo.frame.size.height + 11;
    CGRect contentFrame = self.contentView.frame;
    contentFrame.size.height = basicInfoHeight + offerTipHeight + productPriceHeight + ExclusiveMobilePhoneHeight + WhiteIouHeight + promotionHeight;
    self.contentView.frame = contentFrame;
    
#pragma mark 创建促销点击事件
    [self.contentView addSubview:self.promotionButton];
    self.promotionButton.backgroundColor = [UIColor clearColor];
    [self.promotionButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.promotionLine.bottom);
        make.left.equalTo(self.contentView.left);
        make.right.equalTo(self.contentView.right);
        make.height.equalTo(promotionHeight);
    }];
    [self.promotionButton addTarget:self action:@selector(promotionClick) forControlEvents:UIControlEventTouchUpInside];
   }

- (void)promotionClick{
    NSLog(@"促销");
}
- (CGFloat)fitSizeHeight{
    return basicInfoHeight + offerTipHeight + productPriceHeight + ExclusiveMobilePhoneHeight + WhiteIouHeight + promotionHeight +5;
    
}





- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)dealloc{
    
    if (self.countdown.time) {
        [self.countdown.time invalidate];
        self.countdown.time = nil;
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}









@end
